package com.yanqu.road.entity.activity.washe.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.activity.washe.config.WasheConfig;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 玩家数据
 */
@FieldTypeAnnotation(tableName = "t_u_washe_user")
public class WasheUserData extends DataObject {

    @FieldTypeAnnotation(desc = "玩家ID", select = true, update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "荣誉点")
    private long score;
    @FieldTypeAnnotation(desc = "解锁的卡牌")
    private Set<Integer> unlockCard = new HashSet<>();
    @FieldTypeAnnotation(desc = "解锁的盘面技能")
    private Set<Integer> unlockSkill = new HashSet<>();
    @FieldTypeAnnotation(desc = "各赛季最终荣誉点")
    private ConcurrentHashMap<Integer, Long> seasonScoreMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "各赛季最高荣誉点")
    private ConcurrentHashMap<Integer, Long> seasonTopScoreMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "翻倍buff次数，0持续翻倍，-1无次数")
    private int buffTimes = -1;
    @FieldTypeAnnotation(desc = "连胜收集buff次数")
    private int buffCollectTimes;

    @FieldTypeAnnotation(desc = "买银战令赛季")
    private Set<Integer> silverSet = new HashSet<>();
    @FieldTypeAnnotation(desc = "买金战令赛季")
    private Set<Integer> goldSet = new HashSet<>();

    @FieldTypeAnnotation(desc = "计时宝箱")
    private List<WasheBoxData> boxDataList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "赛季，初始-1")
    private int dataSeason = WasheConfig.SEASON_ID_NULL;
    @FieldTypeAnnotation(desc = "是否新手阶段")
    private boolean guide = true;

    @FieldTypeAnnotation(desc = "赛季回忆观看记录")
    private List<Integer> memorySeeList = new ArrayList<>(); // 数据库字段名是：inGameMomentList

    @FieldTypeAnnotation(desc = "有算奖励的对战局数")
    private long playTimes;

    @FieldTypeAnnotation(desc = "连败次数")
    private long continueFailTimes; // 废弃

    @FieldTypeAnnotation(desc = "现金礼包")
    private ConcurrentHashMap<Integer, WasheRmbMallData> rmbMallMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "瓦舍赛季游戏时长")
    private long seasonPlayTime;
    @FieldTypeAnnotation(desc = "瓦舍今日游戏时长")
    private long todayPlayTime;
    @FieldTypeAnnotation(desc = "每日重置时间")
    private long dayResetTime;

    @FieldTypeAnnotation(desc = "今日对局数")
    private int dayPlayTimes;
    @FieldTypeAnnotation(desc = "今日投降数")
    private int daySurrenderTimes;
    @FieldTypeAnnotation(desc = "连胜次数")
    private int continueWinTimes;

    @FieldTypeAnnotation(desc = "选择的盘面技能")
    private List<Integer> selectedSkill = new ArrayList<>();

    @FieldTypeAnnotation(desc = "上次领取分享奖励时间（0点时间戳）/s")
    private long shareRewardTime;

    @FieldTypeAnnotation(desc = "是否完成外链引导")
    private boolean linkGuide;

    @FieldTypeAnnotation(desc = "使用的各种皮肤")
    private Map<Integer, Integer> decorationMap = new ConcurrentHashMap<>();

    // =========================================

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        if (this.score != score) {
            this.score = score;
            setOp(DataStatus.Update);
        }
    }

    public Set<Integer> getUnlockCard() {
        return unlockCard;
    }

    public void setUnlockCard(Set<Integer> unlockCard) {
        if (null == unlockCard) {
            return;
        }
        if (this.unlockCard == null || !this.unlockCard.equals(unlockCard)) {
            this.unlockCard = unlockCard;
            setOp(DataStatus.Update);
        }
    }

    public Set<Integer> getUnlockSkill() {
        return unlockSkill;
    }

    public void setUnlockSkill(Set<Integer> unlockSkill) {
        if (null == unlockSkill) {
            return;
        }
        if (this.unlockSkill == null || !this.unlockSkill.equals(unlockSkill)) {
            this.unlockSkill = unlockSkill;
            setOp(DataStatus.Update);
        }
    }

    public ConcurrentHashMap<Integer, Long> getSeasonScoreMap() {
        return seasonScoreMap;
    }

    public void setSeasonScoreMap(ConcurrentHashMap<Integer, Long> seasonScoreMap) {
        if (null == seasonScoreMap) {
            return;
        }
        if (this.seasonScoreMap == null || !this.seasonScoreMap.equals(seasonScoreMap)) {
            this.seasonScoreMap = seasonScoreMap;
            setOp(DataStatus.Update);
        }
    }

    public ConcurrentHashMap<Integer, Long> getSeasonTopScoreMap() {
        return seasonTopScoreMap;
    }

    public void setSeasonTopScoreMap(ConcurrentHashMap<Integer, Long> seasonTopScoreMap) {
        if (null == seasonTopScoreMap) {
            return;
        }
        if (this.seasonTopScoreMap == null || !this.seasonTopScoreMap.equals(seasonTopScoreMap)) {
            this.seasonTopScoreMap = seasonTopScoreMap;
            setOp(DataStatus.Update);
        }
    }

    public int getBuffTimes() {
        return buffTimes;
    }

    public void setBuffTimes(int buffTimes) {
        if (this.buffTimes != buffTimes) {
            this.buffTimes = buffTimes;
            setOp(DataStatus.Update);
        }
    }

    public int getBuffCollectTimes() {
        return buffCollectTimes;
    }

    public void setBuffCollectTimes(int buffCollectTimes) {
        if (this.buffCollectTimes != buffCollectTimes) {
            this.buffCollectTimes = buffCollectTimes;
            setOp(DataStatus.Update);
        }
    }

    public Set<Integer> getSilverSet() {
        return silverSet;
    }

    public void setSilverSet(Set<Integer> silverSet) {
        if (null == silverSet) {
            return;
        }
        if (this.silverSet == null || !this.silverSet.equals(silverSet)) {
            this.silverSet = silverSet;
            setOp(DataStatus.Update);
        }
    }

    public Set<Integer> getGoldSet() {
        return goldSet;
    }

    public void setGoldSet(Set<Integer> goldSet) {
        if (null == goldSet) {
            return;
        }
        if (this.goldSet == null || !this.goldSet.equals(goldSet)) {
            this.goldSet = goldSet;
            setOp(DataStatus.Update);
        }
    }

    public List<WasheBoxData> getBoxDataList() {
        return boxDataList;
    }

    public void setBoxDataList(List<WasheBoxData> boxDataList) {
        if (null == boxDataList) {
            return;
        }
        if (this.boxDataList == null || !this.boxDataList.equals(boxDataList)) {
            this.boxDataList = boxDataList;
            setOp(DataStatus.Update);
        }
    }

    public int getDataSeason() {
        return dataSeason;
    }

    public void setDataSeason(int dataSeason) {
        if (this.dataSeason != dataSeason) {
            this.dataSeason = dataSeason;
            setOp(DataStatus.Update);
        }
    }

    public List<Integer> getMemorySeeList() {
        return memorySeeList;
    }

    public void setMemorySeeList(List<Integer> memorySeeList) {
        if (memorySeeList == null) {
            return;
        }
        this.memorySeeList = memorySeeList;
        setOp(DataStatus.Update);
    }

    public boolean isGuide() {
        return guide;
    }

    public void setGuide(boolean guide) {
        if (this.guide != guide) {
            this.guide = guide;
            setOp(DataStatus.Update);
        }
    }

    public long getPlayTimes() {
        return playTimes;
    }

    public void setPlayTimes(long playTimes) {
        if (this.playTimes != playTimes) {
            this.playTimes = playTimes;
            setOp(DataStatus.Update);
        }
    }

    public long getContinueFailTimes() {
        return continueFailTimes;
    }

    public void setContinueFailTimes(long continueFailTimes) {
        if (this.continueFailTimes != continueFailTimes) {
            this.continueFailTimes = continueFailTimes;
            setOp(DataStatus.Update);
        }
    }

    public ConcurrentHashMap<Integer, WasheRmbMallData> getRmbMallMap() {
        return rmbMallMap;
    }

    public void setRmbMallMap(ConcurrentHashMap<Integer, WasheRmbMallData> rmbMallMap) {
        if (rmbMallMap == null) {
            return;
        }
        this.rmbMallMap = rmbMallMap;
        setUpdateOption();
    }

    public long getSeasonPlayTime() {
        return seasonPlayTime;
    }

    public void setSeasonPlayTime(long seasonPlayTime) {
        if (this.seasonPlayTime != seasonPlayTime) {
            this.seasonPlayTime = seasonPlayTime;
            setUpdateOption();
        }
    }

    public long getTodayPlayTime() {
        return todayPlayTime;
    }

    public void setTodayPlayTime(long todayPlayTime) {
        if (this.todayPlayTime != todayPlayTime) {
            this.todayPlayTime = todayPlayTime;
            setUpdateOption();
        }
    }

    public long getDayResetTime() {
        return dayResetTime;
    }

    public void setDayResetTime(long dayResetTime) {
        if (this.dayResetTime != dayResetTime) {
            this.dayResetTime = dayResetTime;
            setUpdateOption();
        }
    }

    public int getDayPlayTimes() {
        return dayPlayTimes;
    }

    public void setDayPlayTimes(int dayPlayTimes) {
        if (this.dayPlayTimes != dayPlayTimes) {
            this.dayPlayTimes = dayPlayTimes;
            setUpdateOption();
        }
    }

    public int getDaySurrenderTimes() {
        return daySurrenderTimes;
    }

    public void setDaySurrenderTimes(int daySurrenderTimes) {
        if (this.daySurrenderTimes != daySurrenderTimes) {
            this.daySurrenderTimes = daySurrenderTimes;
            setUpdateOption();
        }
    }

    public int getContinueWinTimes() {
        return continueWinTimes;
    }

    public void setContinueWinTimes(int continueWinTimes) {
        if (this.continueWinTimes != continueWinTimes) {
            this.continueWinTimes = continueWinTimes;
            setUpdateOption();
        }
    }

    public List<Integer> getSelectedSkill() {
        return selectedSkill;
    }

    public void setSelectedSkill(List<Integer> selectedSkill) {
        if (selectedSkill != null && selectedSkill.size() == 2) { // 这边写死了技能数量
            this.selectedSkill = selectedSkill;
            setUpdateOption();
        }
    }

    public long getShareRewardTime() {
        return shareRewardTime;
    }

    public void setShareRewardTime(long shareRewardTime) {
        if (this.shareRewardTime != shareRewardTime) {
            this.shareRewardTime = shareRewardTime;
            setUpdateOption();
        }
    }

    public boolean isLinkGuide() {
        return linkGuide;
    }

    public void setLinkGuide(boolean linkGuide) {
        if (this.linkGuide != linkGuide) {
            this.linkGuide = linkGuide;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getDecorationMap() {
        return decorationMap;
    }

    public void setDecorationMap(Map<Integer, Integer> decorationMap) {
        this.decorationMap = decorationMap;
    }

    public void setDecorationByType(int type, int id) {
        if (decorationMap == null) {
            decorationMap = new ConcurrentHashMap<>();
        }
        decorationMap.put(type, id);
        setUpdateOption();
    }

}
